package mr

//
// RPC definitions.
//
// remember to capitalize all names.
//

import "os"
import "strconv"

//
// example to show how to declare the arguments
// and reply for an RPC.
//

type ExampleArgs struct {
	X int
}

type ExampleReply struct {
	Y int
}

// Add your RPC definitions here.

type CommandType int

const (
	// task args
	TASK_WAIT CommandType = 0
	TASK_APPLY CommandType = 1
	MAP_FINISH CommandType = 2
	REDUCE_FINISH CommandType = 3
	PING_SERVER = 10

	// task reply
	WORK_MAP CommandType = 20
	WORK_REDUCE CommandType = 21
	WORK_FINISH CommandType = 22
)

type TaskArgs struct {
	MsgType CommandType
	TaskIdx int
}

type TaskReply struct {
	WorkType CommandType
	FileName string
	MapIdx int
	ReduceIdx int
	NReduce int
	NMap int
}

// Cook up a unique-ish UNIX-domain socket name
// in /var/tmp, for the master.
// Can't use the current directory since
// Athena AFS doesn't support UNIX-domain sockets.
func masterSock() string {
	s := "/var/tmp/824-mr-"
	s += strconv.Itoa(os.Getuid())
	return s
}
